package com.lm.redisson.controller;

import jakarta.annotation.Resource;
import org.redisson.api.RMap;
import org.redisson.api.RedissonClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/map")
public class MapController {

    @Resource
    private RedissonClient redissonClient;

    @GetMapping("/set")
    public String set() {
        RMap<String, Object> map = redissonClient.getMap("user-map");
        map.put("name", "Tom");
        map.put("age", 18);
        return "set ok";
    }

    @GetMapping("/get")
    public Object get() {
        return redissonClient.getMap("user-map").get("name");
    }
}

